package com.aurora.blog.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aurora.common.log.annotation.Log;
import com.aurora.common.log.enums.BusinessType;
import com.aurora.common.security.annotation.RequiresPermissions;
import com.aurora.blog.domain.BlogIndexpageContent;
import com.aurora.blog.service.IBlogIndexpageContentService;
import com.aurora.common.core.web.controller.BaseController;
import com.aurora.common.core.web.domain.AjaxResult;
import com.aurora.common.core.utils.poi.ExcelUtil;
import com.aurora.common.core.web.page.TableDataInfo;

/**
 * 网站首页展示信息Controller
 * 
 * @author aurora
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/blogIndexContent")
public class BlogIndexpageContentController extends BaseController
{
    @Autowired
    private IBlogIndexpageContentService blogIndexpageContentService;

    /**
     * 查询网站首页展示信息列表
     */
    @RequiresPermissions("blog:blogIndexContent:list")
    @GetMapping("/list")
    public TableDataInfo list(BlogIndexpageContent blogIndexpageContent)
    {
        startPage();
        List<BlogIndexpageContent> list = blogIndexpageContentService.selectBlogIndexpageContentList(blogIndexpageContent);
        return getDataTable(list);
    }
    /**
     * 导出网站首页展示信息列表
     */
    @RequiresPermissions("blog:blogIndexContent:export")
    @Log(title = "网站首页展示信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlogIndexpageContent blogIndexpageContent)
    {
        List<BlogIndexpageContent> list = blogIndexpageContentService.selectBlogIndexpageContentList(blogIndexpageContent);
        ExcelUtil<BlogIndexpageContent> util = new ExcelUtil<BlogIndexpageContent>(BlogIndexpageContent.class);
        util.exportExcel(response, list, "网站首页展示信息数据");
    }

    /**
     * 获取网站首页展示信息详细信息
     */
    @RequiresPermissions("blog:blogIndexContent:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(blogIndexpageContentService.selectBlogIndexpageContentById(id));
    }
    /**
     * 获取网站首页展示信息详细信息
     */
    @GetMapping("/getIndexContent/{id}")
    public AjaxResult getIndexContent(@PathVariable("id") Long id)
    {
        return success(blogIndexpageContentService.selectBlogIndexpageContentById(id));
    }
    /**
     * 新增网站首页展示信息
     */
    @RequiresPermissions("blog:blogIndexContent:add")
    @Log(title = "网站首页展示信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlogIndexpageContent blogIndexpageContent)
    {
        return toAjax(blogIndexpageContentService.insertBlogIndexpageContent(blogIndexpageContent));
    }

    /**
     * 修改网站首页展示信息
     */
    @RequiresPermissions("blog:blogIndexContent:edit")
    @Log(title = "网站首页展示信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlogIndexpageContent blogIndexpageContent)
    {
        return toAjax(blogIndexpageContentService.updateBlogIndexpageContent(blogIndexpageContent));
    }

    /**
     * 删除网站首页展示信息
     */
    @RequiresPermissions("blog:blogIndexContent:remove")
    @Log(title = "网站首页展示信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(blogIndexpageContentService.deleteBlogIndexpageContentByIds(ids));
    }
}
